
package net.atremmedia.gwt.actionjava.examples.bitmap.samples;

import net.atremmedia.gwt.actionjava.examples.AJExample;
import net.atremmedia.gwt.actionjava.examples.frame.AJExampleOverview;
import actionjava.display.Graphics;
import actionjava.display.Shape;
import actionjava.display.Sprite;
import actionjava.events.tick.TickEvent;
import actionjava.geom.Color;

public class BitmapExample2 extends AJExample
{
	public static final String NAME = "BitmapExample 2";
	public static final String DESCRIPTION = "Description";
	public static final String EXAMPLE_SRC = "https://code.google.com/p/gwt-actionjava/source/browse/trunk/aj-examples/aj-examples-bitmap/src/main/java/net/atremmedia/gwt/actionjava/examples/bitmap/samples/BitmapExample2.java";

	private Sprite rotationContainer;
	private Shape circle1;
	private Shape circle2;
	private Shape circle3;
	private Shape circle4;

	public BitmapExample2(AJExampleOverview base)
	{
		super(NAME, DESCRIPTION, EXAMPLE_SRC, base);
	}

	@Override
	public void run()
	{
		rotationContainer = new Sprite();
		rotationContainer.setX(250);
		rotationContainer.setY(250);

		circle1 = new Shape();
		Graphics graph = circle1.getGraphics();
		graph.beginFill(Color.getRGBA(0xFF0000, .5));
		graph.drawCircle(0, 0, 50);
		graph.endFill();
		circle1.setX(0);
		circle1.setY(-125);
		rotationContainer.addChild(circle1);

		circle2 = new Shape();
		graph = circle2.getGraphics();
		graph.beginFill(Color.getRGBA(0x00FF00, .5));
		graph.drawCircle(0, 0, 50);
		graph.endFill();
		circle2.setX(-125);
		circle2.setY(0);
		rotationContainer.addChild(circle2);

		circle3 = new Shape();
		graph = circle3.getGraphics();
		graph.beginFill(Color.getRGBA(0x0000FF, .5));
		graph.drawCircle(0, 0, 50);
		graph.endFill();
		circle3.setX(125);
		circle3.setY(0);
		rotationContainer.addChild(circle3);

		circle4 = new Shape();
		graph = circle4.getGraphics();
		graph.beginFill(Color.getRGBA(0xF0F0F0, .5));
		graph.drawCircle(0, 0, 50);
		graph.endFill();
		circle4.setX(0);
		circle4.setY(125);
		rotationContainer.addChild(circle4);

		addChild(rotationContainer);
	}

	@Override
	public void onRenderTick(TickEvent event)
	{
		rotationContainer.setRotation(rotationContainer.getRotation() + 3);
	}
}
